<script type="text/javascript" src="/IndexPublic/zchou/js/jquery-1.9.1.min.js"></script>
    <script type="text/javascript">
        //调用微信JSapi 支付
        function jsApiCall(){
            WeixinJSBridge.invoke(
                'getBrandWCPayRequest',{$jsApiParameters},
                function(res){
                    //writeObj(res);
                    //return false;
                    //WeixinJSBridge.log(res.err_msg);
                    if(res.err_msg == 'get_brand_wcpay_request:ok') {
                    	//alert("支付成功！");
						//location.href=decodeURIComponent("{$url}");

                        /*支付成功，操作API进行交易记录*/
                        var geturl = '{$payinfo['geturl']}';              //支付成功返回的地址
                        var liveid = '{$payinfo['liveid']}';              //直播ID号
                        var bodystr = '{$payinfo['bodystr']}';            //直播名称
                        var userinfo = '{$payinfo['userinfo']}';          //用户微信TOKEN
                        var cordernumber = '{$payinfo['cordernumber']}';  //自定义订单号
                        var money = '{$payinfo['money']}';                //支付金额
                        var protype = '{:C('PROTYPE1')}';                 //项目类型（这里是liveitem）

                        var tourl = "/Live/Pay/paysuccess";
                        var todata = {
                            "money":money,
                            "liveid":liveid,
                            "bodystr":bodystr,
                            "userinfo":userinfo,
                            "protype":protype,
                            "cordernumber":cordernumber,
                            random:Math.random()
                        };
                        $.ajax({
                            url:tourl,
                            data:todata,
                            type:"POST",
                            dataType:"html",
                            success:function (data){
                                //alert(data);
                                //return false;
                                if(data>0){
                                    location.href=geturl;
                                }else{
                                    alert("记录失败-！");
                                }
                            }
                        });
	                }else{
                        alert("支付失败！");
                        location.href="{$payinfo['geturl']}";
                        return false;
	                }
            	}
            );
        }
        function callpay(){
            if (typeof WeixinJSBridge == "undefined"){
                if( document.addEventListener ){
                    document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
                }else if (document.attachEvent){
                    document.attachEvent('WeixinJSBridgeReady', jsApiCall); 
                    document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
                }
            }else{
                jsApiCall();
            }
        }
        callpay();

        function writeObj(obj){
            var description = "";
            for(var i in obj){
                var property=obj[i];
                description+=i+" = "+property+"\n";
            }
            alert(description);
        }
    </script>